<?php
my_component_load('testing' , false);
my_component_load('paging' , false); 
my_component_load('data_setting', false);
my_component_load('grievance' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$kid = isset( $_GET['kid'] ) ? $_GET['kid']:  0;
$sid = isset( $_GET['sid'] ) ? $_GET['sid']:  0;
$pid = isset( $_GET['pid'] ) ? $_GET['pid']:  0;
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$modulname = "Admin _BN_ Konfigurasi Data _BN_ Grievance";

if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "grievance_periode_page" :
			$validatepost = form_grievance_periode_validate($pid);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_grievance_periode_create($pid);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_grievance_periode_submit($pid);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=grievance');
			break;	
		case   "grievance_kelompok_page" :
			$validatepost = form_grievance_kelompok_validate($pid,$id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_grievance_kelompok_create($pid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_grievance_kelompok_submit($pid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=grievance');
			break;
		case   "grievance_sub_page" :
			$validatepost = form_grievance_sub_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_grievance_sub_create($kid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_grievance_sub_submit($kid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=grievance&task=list_grievance_sub&kid='.$kid);
			break;			
		case   "grievance_page" :
			$validatepost = form_grievance_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_grievance_create($sid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_grievance_submit($sid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=grievance&task=list_grievance&sid='.$sid);
			break;	
	}
else: 
	if($task == "grievance_kelompok_page"){   
		$content  = form_grievance_kelompok_create($id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "grievance_kelompok_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data Kelompok Grievance" : "Tambah Data Kelompok Grievance";
		facebox_page('index.php?com=grievance&task=grievance_kelompok_page&pid='.$pid.'&id='.$id , $title , 180	);
	}elseif($task =='grievance_kelompok_delete'){
		 delete_grievance_kelompok($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
		 
	}elseif($task =='list_grievance_sub'){	
		$pagename = "Sub Grievance";
		load_facebox_script();
		$view =  list_grievance_sub($kid); 
		$href = 'index.php?com=grievance&task=grievance_sub_create&kid='.$kid.'&id=0';
	}elseif($task == "grievance_sub_page"){ 
		$content  = form_grievance_sub_create($kid,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "grievance_sub_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data Sub Grievance" : "Tambah Data Sub Grievance";
		facebox_page('index.php?com=grievance&task=grievance_sub_page&kid='.$kid.'&id='.$id , $title , 210	);
	}elseif($task =='grievance_sub_delete'){
		 delete_grievance_sub($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
		 
	}elseif($task =='list_grievance'){		 
		$pagename = "Daftar Grievance";
		load_facebox_script();
		$view =  list_grievance($sid); 
		$href = 'index.php?com=grievance&task=grievance_create&sid='.$sid.'&id=0';		
	}elseif($task == "grievance_page"){ 
		$content  = form_grievance_create($sid,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "grievance_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data Unit grievance" : "Tambah Data Unit grievance";
		facebox_page('index.php?com=grievance&task=grievance_page&sid='.$sid.'&id='.$id , $title , 220	);
	}elseif($task =='grievance_delete'){
		 delete_grievance($id);
		 my_direct($_SERVER['HTTP_REFERER']);		
		 
	}elseif($task =='list_grievance_kelompok'){
		$pagename = "Kelompok Grievance";
		load_facebox_script();
		$view =  list_grievance_kelompok($pid); 
		$href = 'index.php?com=grievance&task=grievance_kelompok_create&pid='.$pid;		
	}elseif($task == "grievance_kelompokpage"){ 
		$content  = form_grievance_kelompok_create($pid, $id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "grievance_kelompok_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=grievance&task=grievance_kelompok_page&pid='.$pid.'&o=1' , $title , 220	);
	}elseif($task =='grievance_kelompok_delete'){
		 delete_kelompok_grievance($id);
		 my_direct($_SERVER['HTTP_REFERER']);						

		
	}elseif($task == "grievance_periode_page"){ 
		$content  = form_grievance_periode_create($pid);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "grievance_periode_create"){ 
		$title= ($pid > '0' ) ?  "Perubahan Data Periode grievance" : "Tambah Data Periode grievance";
		facebox_page('index.php?com=grievance&task=grievance_periode_page&pid='.$pid , $title , 220	);
	}elseif($task =='grievance_periode_delete'){
		 delete_periode_grievance($id);
		 my_direct($_SERVER['HTTP_REFERER']);			
	}else{
		$pagename = "Periode Grievance";
		load_facebox_script();
		$view =  list_periode(); 
		$href = 'index.php?com=grievance&task=grievance_periode_create';
	}
endif; 
$content = spliter_browser( $view , $pagename ,$href);
generate_my_web($content, $modulname );

?>